package scanSpring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;
public class scanSpring {

    public static void main(String[] args) {
        //加载spring的配置文件
        ApplicationContext ac = new ClassPathXmlApplicationContext("scanSpring.xml");
        EmployerController ec = (EmployerController)ac.getBean("employerController");
        //获取所有员工
        List<Employer> list = ec.findEmployer();
        //获取平均工资
        double avg = ec.getAvgSalary();
        System.out.println("平均工资为"+avg);
        for (Employer e : list) {
            System.out.println(e);
            String result = avg > e.getSalary()?"拖后腿":"做贡献";
            System.out.println("员工工资为"+e.getSalary()+","+result);
        }
    }
}
